const path = require("path");

const resolve = (dir) => {
  return path.join(__dirname, dir);
};

// const BASE_URL = process.env.NODE_ENV === "production" ? "/" : "/";
module.exports = {
  publicPath: process.env.NODE_ENV === "production" ? "/mengAdmin" : "/",
  lintOnSave: process.env.NODE_ENV === 'development',
  outputDir: "dist",
  assetsDir: "static",
  devServer: {
    open: true,
    // proxy: "http://10.7.232.78:8080",
    overlay: {
      warnings: false,
      errors: true,
    },
    proxy: {
      // detail: https://cli.vuejs.org/config/#devserver-proxy
      [process.env.VUE_APP_BASE_API]: {
        target: `http://localhost:8088`,
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    },
    //before: require("./mock/mock-server.js"),
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set("@", resolve("src")) // key,value自行定义，比如.set('@@', resolve('src/components'))
      .set("_c", resolve("src/components"))
    
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  },
  // 设为false打包时不生成.map文件
  productionSourceMap: false,
};
